<?php

function member_favorite_restaurants_page(){
    global $user;
    $header = array(
	array('data' => 'Étterem neve:', 'field' => 'name', 'sort' => 'asc'),
	array('data' => 'Város', 'field' => 'city'),
	array('data' => 'Website', 'field' => 'website'),
        array('data' => 'Telefon', 'field' => 'telephone'),
        array('data' => 'Nyitvatartás', 'field' => 'open'),
        array('data' => 'Házhozszállítás', 'field' => 'delivery'),
        array('data' => 'Wifi', 'field' => 'wifi'),
        array('data' => 'Parkolás', 'field' => 'parking'),
    );
    $query = db_select('ep_favourite_restaurant', 'fr');
    $query->join('ep_restaurants', 'r', 'fr.rid = r.rid');
    $query->fields('fr',array('rid','uid'))
            ->fields('r',array('name','city','website','telephone','open','delivery','wifi','parking'))
            ->condition('fr.uid',$user->uid,'=');
    $results = $query
            ->execute();
    $rows = array();
    foreach ($results as $favourite) {
    $rows[] = array(
	'data' => array(
                            '<a href="'.url('member/restaurants_offers/'.$favourite->rid).'">'.$favourite->name.member_add_restaurant_to_favourite_control($favourite->rid),
                            $favourite->city,
                            $favourite->website,
                            $favourite->telephone,
                            $favourite->open,
                            $favourite->delivery?t('igen'):t('nem'),
                            $favourite->wifi?t('igen'):t('nem'),
                            $favourite->parking?t('igen'):t('nem'),
           
           )
        );
    }
    $html = theme('table', 
                array(
		 'header' => $header,
                 'rows'=>$rows,
		 'sticky' => TRUE,		
		 'empty' => t('Nincs elem ebben a listában...'),
                 )
		);
     
        
   return $html;
}